package com.dayuanit.dy15.ebook.bookshop.controller;

import com.dayuanit.dy15.ebook.bookshop.dto.ResponseDTO;
import com.dayuanit.dy15.ebook.bookshop.service.CardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CardController extends BaseController {

    @Autowired
    private CardService cardService;

    @RequestMapping("/card/addCard")
    public ResponseDTO addCard(long commodityId) {
        cardService.addCard(commodityId, getUserId());
        return ResponseDTO.sucess();
    }

    @RequestMapping("/card/listCards")
    public ResponseDTO listCards() {
        return ResponseDTO.sucess(cardService.listCards(getUserId()));
    }

    @RequestMapping("/card/deleteCard")
    public ResponseDTO deleteCard(long cardId) {
        cardService.deleteCard(getUserId(), cardId);
        return ResponseDTO.sucess();
    }

}
